(function($) {
	$.extend({
		tipsBox: function(options) {
			options = $.extend({
				obj: null, //jq对象，要在那个html标签上显示
				str: "+1", //字符串，要显示的内容;也可以传一段html，如: "<b style='font-family:Microsoft YaHei;'>+1</b>"
				startSize: "12px", //动画开始的文字大小
				endSize: "30px", //动画结束的文字大小
				interval: 600, //动画时间间隔
				color: "#cd4450", //文字颜色
				weight: "bold", //文字
				callback: function() {} //回调函数
			}, options);

			$("body").append("<span class='num'>" + options.str + "</span>");
			var count = $("#dianzan").html();
			$("#dianzan").html(++count);

			var box = $(".num");
			var left = options.obj.offset().left + options.obj.width() / 2;
			var top = options.obj.offset().top - options.obj.height();
			box.css({
				"position": "absolute",
				"left": left + "px",
				"top": top + "px",
				"z-index": 9999,
				"font-size": options.startSize,
				"line-height": options.endSize,
				"color": options.color,
				"font-weight": options.weight
			});
			box.animate({
				"font-size": options.endSize,
				"opacity": "0",
				"top": top - parseInt(options.endSize) + "px"
			}, options.interval, function() {
				box.remove();
				options.callback();
			});
		}
	});
})(jQuery);

var temp = 0;
var dianzan = document.getElementById("btn1");

$(function() {
	$("#btn1").click(function() {
		if(temp == 0) {
			dianzan.innerHTML = "取消";
			temp = 1;
		} else {
			temp = 0;
			dianzan.innerHTML = "点赞";
		}
		
		var url;
		if(temp == 1){
			url = "/updateDZ";
		}else{
			url = "/cancelDrag"
		}
		$.get(
			url,
			function(data) {});

		$.tipsBox({
			obj: $(this),
			str: "+ 1",
			callback: function() {}
		});
	});

});

/**
 * 评论的功能实现
 */

$("#commit").click(function() {
	
	var text = $("#memo").val();
	var message = {
		"pllr": text
	};
	var jsonData = JSON.stringify(message);

	$.ajax({
		type: "post",
		url: "/commit",
		data: jsonData,
		dataType: "json",
		contentType: "application/json;charset=UTF-8",
		success: function(data) {

		}
	});
	$("#memo").val("");
	$("#fabu").hide(500);
	showPinLun();
	window.setTimeout("refreshPage()", 500);
});

function showPinLun(){
	
}


function refreshPage() {
	window.location.reload();
}

var status = 0;
$("#btn2").click(function() {
	if(status == 0){
		$("#fabu").show(500);
		status = 1;
	}else{
		status = 0;
		$("#fabu").hide(500);
		
	}
	
});